#include <iostream>

#include <gtkmm/main.h>
#include <libglademm/xml.h>
#include <gtkglmm.h>

#include "LSDWindow.h"

#include "CErrorMsg.h"

#include "config.h"


/////////////////////////////////////////////////////////////

int main(int argc, char* argv[])
{
  Gtk::Main kit(argc,argv);
  Gtk::GL::init(argc,argv);

  Glib::RefPtr<Gnome::Glade::Xml> refXml;

  LSDWindow* lsd_window(0);

  try
    {
      refXml = Gnome::Glade::Xml::create(LSD_DATADIR "/" "lsd.glade");
      lsd_window = refXml->get_widget_derived("MainWindow",lsd_window);
    }
  catch(Gnome::Glade::XmlError& e)
    {
      std::cerr << PACKAGE_STRING ": " << e.what() << std::endl;
      return 1;
    }
  catch(Glib::Error& e)
    {
      std::cerr << PACKAGE_STRING ": " << e.what() << std::endl;
      return 2;
    }
  catch(CErrorMsg& e)
    {
      std::cerr << PACKAGE_STRING ": " << e.what() << std::endl;
      return 3;
    }
  
  if(lsd_window)
    kit.run(*lsd_window);

  return 0;
}
